package com.intelligent.mts.client.listener;

import com.google.common.eventbus.Subscribe;
import com.intelligent.mts.client.core.view.BomManagePanel;
import com.intelligent.mts.client.event.DialogStatusBarEvent;
import com.intelligent.mts.client.ex.MyDialog;
import com.intelligent.mts.client.utils.ApplicationBeanUtils;

import java.awt.*;

/**
 * Created by Garen.Pang on 2016/8/23.
 */
public class MyDialogListener {

    @Subscribe
    public void receivedMsg(DialogStatusBarEvent event) {
        resetStatusValue(event);
    }

    private void resetStatusValue(DialogStatusBarEvent event) {
        String message = event.getMessage();
        String level = event.getLevel();

        if(message == null) {
            message = "";
        }

        Color color = Color.black;
        if(DialogStatusBarEvent.MSG_LEVEL_ERROR.equals(level)) {
            color = Color.red;
        }

        ApplicationBeanUtils.getBean(BomManagePanel.class).myDialog.setStatusValue(message, color);
    }

    
}
